package com.ylfstu.innerclass;

public class MemberInnerClass {
    public static void main(String[] args) {
        Outer04 outer04 = new Outer04();
        outer04.t1();
        //外部其他类，使用成员内部类的三种方式
        //第一种
        //outer04.new Inner04(), 相当于把 new Inner04() 当做是outer04的成员
        Outer04.Inner04 inner04 = outer04.new Inner04();

        //第二种 在外部类中，编写一个方法，可以返回Inner04对象
        Outer04.Inner04 inner04Instance = outer04.getInner04Instance();
        inner04Instance.say();
    }
}

class Outer04 {
    private int n1 = 10;
    private String name = "张三";

    //成员内部类
    class Inner04 {
        public void say() {
            System.out.println("n1=" + n1 + "name=" + name);
        }
    }

    public void t1() {
        Inner04 inner04 = new Inner04();
        inner04.say();
    }

    public Inner04 getInner04Instance() {
        return new Inner04();
    }
}
